class AutoStation < ActiveRecord::Base
  set_table_name "stations"
  belongs_to :auto_course
  file_column :image1
  file_column :image2
  file_column :image3
  file_column :image4

  def round
    "<a href='/station/manage/#{id}'>Manage</a>".html_safe
  end

  def round2
    "<a href='/user_station/station_calendar/#{id}'>จอง</a>".html_safe
  end

  def show_image1
    word = ''
    begin
      word = "<img src='/auto_station/image1/#{id}/#{image1.split('/').last}'/>".html_safe
    rescue
      word = ''
    end
    return word
  end

  def show_image2
    word = ''
    begin
      word = "<img src='/auto_station/image2/#{id}/#{image2.split('/').last}'/>".html_safe
    rescue
      word = ''
    end
    return word
  end

  def show_image3
    word = ''
    begin
      word = "<img src='/auto_station/image3/#{id}/#{image3.split('/').last}'/>".html_safe
    rescue
      word = ''
    end
    return word
  end

  def show_image4
    word = ''
    begin
      word = "<img src='/auto_station/image4/#{id}/#{image4.split('/').last}'/>".html_safe
    rescue
      word = ''
    end
    return word
  end

  def show_code
    word = ''
    begin
      word = "#{map_code}".html_safe
    rescue
      word = ''
    end
    return word
  end
end
